﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PowerCreator.LMS.Common.Script;

//using PowerCreator.LMS.Model.Entity;
//using PowerCreator.LMS.Logic.CourseManager;
//using PowerCreator.LMS.Logic.Common;
//using PowerCreator.LMS.Logic.UserManager;
//using PowerCreator.LMS.Logic.ProjectManager;

public partial class sysadmin_CountManager_ProjectInfo : PowerCreator.LMS.Web.Base.BasePage
{
    //ManagerProjectInfo manager = new ManagerProjectInfo();
    
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!GetRole(Role.CountProject))
        //{
        //    Script.ShowAndHistory("您没有培训方案统计的权限!", -1);
        //    return;
        //}
        //if (!IsPostBack)
        //{
        //    string search = GetSearch();
        //    BinderPager(search);
        //    BinderGV(search, 1);
        //}
    }
    private string GetSearch()
    {
        string search = "";
        if (!string.IsNullOrEmpty(txtProjectName.Text.Trim()))
        {
            search = string.Format(" and ProjectName like '%{0}%' ", txtProjectName.Text);
        }
        return search;
    }
    private void BinderPager(string search)
    {
        //AspNetPager1.RecordCount = manager.ProjectListCount(search);
        //AspNetPager1.PageSize = FBasePage.PageSize();
    }
    private void BinderGV(string search, int pageIndex)
    {
    //    DataTable dt = new DataTable();
    //    dt = manager.ProjectList(search, pageIndex, FBasePage.PageSize());
    //    ViewState["dt"] = dt;
    //    dt.Columns.Add("url");
    //    for (int i = 0; i < dt.Rows.Count; i++)
    //    {
    //        dt.Rows[i]["url"] = "p=" + Base64.Encode(dt.Rows[i]["ProjectID"].ToString()) + "&pn=" + Base64.Encode(dt.Rows[i]["ProjectName"].ToString());
    //    }
    //    gvProjectClassList.DataSource = dt;
    //    gvProjectClassList.DataBind();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderPager(search);
        BinderGV(search, 1);
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        string search = GetSearch();
        BinderGV(search, AspNetPager1.CurrentPageIndex);
    }
    protected void gvProjectClassList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string url = string.Empty;
        if (e.CommandName == "btn_SelInfo")
        {
            url = "UserProjectScheduleInfo_New.aspx?" + e.CommandArgument.ToString();
            Script.RedirectURL(url);
        }
        if (e.CommandName == "btn_PassCount")
        {

            //url = "ProjectPassCount.aspx?" + e.CommandArgument.ToString();

            url = "FCProjectPassCount.aspx?" + e.CommandArgument.ToString();
            Script.RedirectURL(url);
        }
    }
    protected void btnExport_Click(object sender, EventArgs e)
    {
        
        //DataTable dt = (DataTable)ViewState["dt"];
        //ExportList(dt);
    }
    private void ExportList(DataTable dt)
    {
        //ArrayList list = new ArrayList();
        //for (int i = 0; i < dt.Columns.Count; i++)
        //{
        //    if (dt.Columns[i].ColumnName == "ProjectID")
        //    {
        //        dt.Columns[i].ColumnName = "方案ID";
        //        dt.Columns[i].SetOrdinal(0);
        //    }
        //    else if (dt.Columns[i].ColumnName == "ProjectName")
        //    {
        //        dt.Columns[i].ColumnName = "方案名称";
        //        dt.Columns[i].SetOrdinal(1);
        //    }
        //    else if (dt.Columns[i].ColumnName == "ClassCount")
        //    {
        //        dt.Columns[i].ColumnName = "班级总数";
        //        dt.Columns[i].SetOrdinal(2);
        //    }
        //    else
        //    {
        //        list.Add(dt.Columns[i].ColumnName);
        //    }
        //}
        //for (int i = 0; i < list.Count; i++)
        //{
        //    dt.Columns.Remove(list[i].ToString());
        //}
        //Excel objExcel = new Excel();
        //objExcel.ToExcel(dt, this.Page, "培训方案统计", "培训方案统计信息", "ProjectInfo");
    }
    protected void btnAllProjectPass_Click(object sender, EventArgs e)
    {
        string url = "AllProjectPass.aspx";
        Script.RedirectURL(url);
    }
    protected void btnAllClassPass_Click(object sender, EventArgs e)
    {
        string url = "AllClassPass.aspx";
        Script.RedirectURL(url);
    }
    protected void btnExport_All_Click(object sender, EventArgs e)
    {
        //string search = GetSearch();
        //DataTable dt = new DataTable();
        //dt = manager.ProjectList(search, 1, manager.ProjectListCount(search));
        //ExportList(dt);
    }
}
